package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.InWarehouse;
import cn.wolfcode.crm.query.JSONResult;
import cn.wolfcode.crm.query.InWarehouseQueryObject;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IInWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("inwarehouse")
public class InWarehouseController {

    @Autowired
    private IInWarehouseService orderBillService;

    //由于dataGrid组件返回必须为json,所以跳转界面就分开
    @RequestMapping("view")
    public String view(){
        return "InWarehouse";
    }

    //编辑界面需要
    @RequestMapping("list")
    @ResponseBody
    public List<InWarehouse> list(){
        return orderBillService.selectAll();
    }

    //页面数据
    @RequestMapping("query")
    @ResponseBody
    public PageResult query(InWarehouseQueryObject qo){
        return orderBillService.query(qo);
    }

    //编辑
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public JSONResult saveOrUpdate(InWarehouse dept){
            orderBillService.saveOrUpdate(dept);
        return new JSONResult();
    }

    //修改状态
    @RequestMapping("audit")
    @ResponseBody
    public JSONResult audit(Long id){
        orderBillService.audit(id);
        return new JSONResult();
    }

}
